package raytracer.objects;

import raytracer.math.Vector3d;
import raytracer.misc.Material;
import raytracer.misc.Ray;

/**
 * Generic class for 3-dimensional objects which always have a material and can be checked
 * for intersection with a given ray
 * @author AlSvartr
 * @version 07.06.2006
 */
public abstract class ThreeDObject {
	
	private Material material;
	private long rayID;
		
	public ThreeDObject() {
		this.setMaterial(new Material());
		this.rayID=Long.MIN_VALUE;
	}
	
	public abstract boolean isInfinite();
	
	public abstract double getMinX();
	public abstract double getMinY();
	public abstract double getMinZ();
	public abstract double getMaxX();
	public abstract double getMaxY();
	public abstract double getMaxZ();
	
	public Vector3d getMinValues() {
		return new Vector3d(getMinX(),getMinY(),getMinZ());
	}
	
	public Vector3d getMaxValues() {
		return new Vector3d(getMaxX(),getMaxY(),getMaxZ());
	}
	
	/**
	 * 
	 * @param ray the ray that should be checked for intersection
	 * @return the distance if there is an intersection, null else
	 */
	public abstract Double intersect(Ray ray, Vector3d intersectionPoint, Vector3d normal);
	
	public void setRayID(long id) {
		this.rayID=id;
	}
	
	public void setMaterial(Material mat) {
		this.material=mat;
	}
	
	public long getRayID() {
		return this.rayID;
	}
	
	public Material getMaterial() {
		return this.material;
	}
	
}
